package ycl.base.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.base.entity.Country;
import ycl.base.req.CountryReq;
import ycl.base.res.CountryRes;
import ycl.base.service.CountryService;
import ycl.common.result.Result;
import ycl.common.base.controller.BaseController;
import ycl.common.models.base.A;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 国家表 前端控制器
 * </p>
 *
 * @author ycl
 * @since 2022-06-22 20:06:26
 */
@RestController
@RequestMapping("/country")
@Api(tags = "国家")
@ApiSupport(order = 1)
public class CountryController
		extends BaseController<Country, CountryReq, CountryRes> {


	@Resource
	private CountryService countryService;

	@Override
	public Result<Page<CountryRes>> pageList(HttpServletRequest request, Country country) {
		return  Result.success(countryService.pageList(request, country, CountryRes.class));
	}

	@Override
	public <E extends CountryReq> Result<A> save(HttpServletRequest request, @RequestBody @Valid E e) {
		countryService.save(request, e, Country.class);
		return Result.success();
	}

	@Override
	public <E extends CountryReq> Result<A> update(HttpServletRequest request, @RequestBody @Valid E e) {
		countryService.update(request, e, Country.class);
		return Result.success();
	}
}

